package com.cljz.makepassenger.widget;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

/**Android禁止ViewPager的左右滑动
 * Created by Administrator on 2016/9/12 0012.
 */
public class NoScrollViewPager extends ViewPager {
    public NoScrollViewPager(Context context) {
        super(context);
    }

    public NoScrollViewPager(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void scrollTo(int x, int y) {
        super.scrollTo(x, y);
    }

    @Override
    public boolean onTouchEvent(MotionEvent arg0) {
        /* return_1 false;//super.onTouchEvent(arg0); */
        //return_1 super.onTouchEvent(arg0);
        return false;
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent arg0) {
        //return_1 super.onInterceptTouchEvent(arg0);
        return false;
    }

    @Override
    public void setCurrentItem(int item, boolean smoothScroll) {
        super.setCurrentItem(item, smoothScroll);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        boolean ret = super.dispatchTouchEvent(ev);
        requestDisallowInterceptTouchEvent(true);
		/*if (ret) {
			requestDisallowInterceptTouchEvent(true);
		}else {
			requestDisallowInterceptTouchEvent(false);
		}*/
        return ret;
    }
//设置当前页的菜单栏
    @Override
    public void setCurrentItem(int item) {
        super.setCurrentItem(item);
    }
}
